﻿using Microsoft.Extensions.DependencyInjection;
using Fast.DynamicProxies;
using System.Threading.Tasks;

namespace Fast.Tests.DynamicProxies
{
    public interface IUserService
    {
        void AddUser(User user);
        Task AddUserAsync(User user);
        Task<User> GetUserAsync();
    }

    [Interceptor(typeof(UserServiceInterceptor))]
    public class UserService : IUserService, ITransientDependency
    {
        public void AddUser(User user)
        {
            System.Console.WriteLine($"public void AddUser(User user)");
        }
        public async Task AddUserAsync(User user)
        {
            System.Console.WriteLine($"public async Task AddUserAsync(User user)");
        }
        public async Task<User> GetUserAsync()
        {
            return new User() { Id = 1, Name = "johnny" };
        }
    }

    public class UserServiceInterceptor : IFastInterceptor
    {
        public void AfterAction(object[] args, object result)
        {

        }

        public void BeforeAction(object[] args)
        {

        }
    }
    public class User
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }
}
